<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models\User;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

/**
 * Class UserWalletrecord
 *
 * @property int $id
 * @property int $user_id
 * @property string $content
 * @property float $money
 * @property int $direction
 * @property Carbon $created_at
 * @property Carbon $updated_at
 *
 * @package App\Models
 */
class UserWalletrecord extends Model
{
	protected $table = 'user_walletrecord';
	protected $casts = [
		'user_id' => 'int',
		'money' => 'float',
		'direction' => 'int'
	];

	protected $fillable = [
		'user_id',
		'content',
		'money',
		'direction', #1入 2出
        'type',//
        'type_id',//
        'remaining_amount', // 余额
        'before_amount',//变动前金额
	];
	const COMMENT = [
	    'id' =>  '记录ID',
        'user_id' => '用户ID',
        'content' => "内容",
        'money' => '金额',
        'direction' => "流向", #1入 2出
        'type' => "记录类型(订单分佣，提现)",//
        'type_id' => "记录ID",//
        'remaining_amount' => '变动后余额', // 余额
        'before_amount' => '变动前余额',//变动前金额
        'created_at' => '创建时间',
        'updated_at' => '更新时间',
    ];

    const DIRECTION_INCREASE = 1; #1入 2出
    const DIRECTION_DECREASE = 2; #1入 2出
    // 流向
    const DIRECTION_ARR = [
        self::DIRECTION_INCREASE => '流入',
        self::DIRECTION_DECREASE => '流出',
    ];
    const TYPE_ARR = [
        'withdrawal' => '提现',
        'order' => '订单分佣'
    ];

    # relation
    public function SystemUser()
    {
        return $this->belongsTo(SystemUser::class,'user_id','id');
    }

}
